package com.tenement.action;

import com.tenement.domain.TenementLog;
import com.tenement.service.LogService;
import com.tenement.utils.Tools;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @ClassName : LogAction  //类名
 * @Description : 日志Controller  //描述
 * @Author : 易嵘  //作者
 * @Date: 2020-06-29 20:41  //时间
 */
@Controller
@RequestMapping("logAction")
public class LogAction {

    @Resource
    LogService logService;

    @ResponseBody
    @RequestMapping("findAll")
    public Map<String,Object> findAll(TenementLog log,
                                      @RequestParam(value = "startDate", required = false) String startDate,
                                      @RequestParam(value = "endDate", required = false) String endDate,
                                      @RequestParam("page") Integer page,
                                      @RequestParam("limit") Integer limit){

        List<TenementLog> logs=logService.findAll(log,startDate,endDate,page,limit);
        Long overCount=logService.overCount(log,startDate,endDate);

        return Tools.maps(overCount,logs);
    }

    @ResponseBody
    @RequestMapping("deleteById")
    public int deleteById(String id){
        return logService.delete(id);
    }

    @ResponseBody
    @RequestMapping("deleteAll")
    public int deleteAll(String ids[]){
        return logService.deleteAll(ids);
    }

    @ResponseBody
    @RequestMapping("findById")
    public TenementLog findById(String logId){
        return logService.findById(logId);
    }
}
